def normalizationIterator(stream, event, current={'startTime': None}):
  if current['startTime'] == None:
    current['startTime'] = event[1]
    current['endTime']   = event[2]
    current['value']     = event[3]
    
    # We can't add this event yet
    return current
  
  if event[2] <= current['endTime']:
    # This event happens before the current event
    # We ignore it
    return current
  
  if event[1] > current['endTime']:
    # These events are not contiguous
    stream[current['startTime']:current['endTime']] = current['value']
    
    current['startTime'] = event[1]
    current['endTime']   = event[2]
    current['value']     = event[3]
    
    return current
  
  if event[3] == current['value']:
    # This event at best prolongs the current event
  
    if event[2] > current['endTime']:
      current['endTime'] = event[2]
  
    return current
  
  stream[current['startTime']:current['endTime']] = current['value']
  
  current['startTime'] = current['endTime']
  current['endTime']   = event[2]
  current['value']     = event[3]
  
  return current
